|
|
|
|
|
|
|
This slows your application down because Visual Basic has to do some significant processing to lookup these methods and properties. |
|
|
|
|
|
|
|
|
One more disadvantage to using generic objects is that theres no compile-time checking done on the arguments passed to these routines. Suppose you were to write a procedure that accepts a String variable as a parameter. If you try to call this procedure and pass an Integer type, youll receive an error message from the compiler. If the compiler did not perform this type checking, you would have to wait until runtime to get this error. This is exactly what happens with generic object variables. Therefore, you wont receive an error until you hit the line of code where the method is called and the object you passed does not support that method. This can slow your development down in that you need to thoroughly test your application for these types of bugsyou wont get any help from the compiler. |
|
|
|
|
|
|
|
|
Objects are Passed by Reference |
|
|
|
|
|
|
|
|
The code fragment that passed the combo and list box to the state loading routine illustrates an important point about object variablestheyre always passed by reference to procedures. This means a pointer to the actual window is passed to procedures. This allows you to change the objects properties in the procedure, and those changes will display on the interface. In fact, there is no way to pass an object variable by value. |
|
|
|
|
|
|
|
|
Visual Basic exposes five global system objects that allow you to query and manipulate your application environment at runtime. These five objects are global and are available anywhere from within your Visual Basic application. Table 21.2 lists the different system objects. |
|
|
|
|
| Table 21.2 System Objects. | | Object | Description | | App | Allows you to query and set information thats specific to your application. | | Clipboard | Allows you to retrieve and place information into the Windows Clipboard. | | Debug | Allows you to print to the Debug window. (This option is not available in your final EXE program.) | | Printer | Allows you to send text and graphics to the printer. |
|
|
|
|
|
|
(table continued on next page) |
|
|
|
|
|